package com.subsequent.controller;

import com.github.pagehelper.PageInfo;
import com.subsequent.dto.ConsultationsQueryDTO;
import com.subsequent.pojo.Consultations;
import com.subsequent.service.ConsultationsService;
import com.subsequent.utils.Result;
import com.subsequent.vo.ConsultationsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/consultations")
public class ConsultationsController {
    @Autowired
    private ConsultationsService consultationsService;

    /**
     * 获取问诊列表
     * @param consultationsQueryDTO
     * @return
     */
    @RequestMapping("/page")
    public Result page(@RequestBody ConsultationsQueryDTO consultationsQueryDTO){
        PageInfo<ConsultationsVO> consultationsList = consultationsService.getConsultationsList(consultationsQueryDTO);
        return Result.success(consultationsList);
    }

    /**
     * 根据问诊id查询问诊详情
     * @param consultationId
     * @return
     */
    @RequestMapping("/byConsultationsId")
    public Result getByConsultationsId(Integer consultationId){
        List<ConsultationsVO> byConsultations = consultationsService.getByConsultations(consultationId);
        return Result.success(byConsultations);
    }

    /**
     * 退费
     * @param consultationsVO
     * @return
     */
    @RequestMapping("/fee")
    public Result updateFee(@RequestBody ConsultationsVO consultationsVO){
        int i = consultationsService.updateFeeInt(consultationsVO);
        return Result.success("已退费",  i);
    }
}
